<template>
	<div>
		<div class="activitiesNinePro" v-if="dataList.length > 0">
			<div class="proul">
				<active-item itemType="C" v-if="moreseedata.relPosition" :moreseedata="moreseedata"></active-item>
				<active-item itemType="G" v-for="(val, index) in productdata" v-show="productdata.length > 0" :detail="val" :key="'activitiesNinePro' + index"></active-item>
				<div style="clear: both;"></div>
			</div>
		</div>
		<div v-if="dataList.length==0 && env === 'edit'" style="height: 2.5rem;line-height: 2.5rem;">请配置商品数据</div>
	</div>
</template>

<script>
	import { queryGoodsList } from '@/utils/ReturnAxios'
	import ActiveItem from '../ActiveItem'
	export default {
		props: {
			dataList: {
				type: Array,
				default: () => []
			}
		},
		data() {
			return {
				codeList: [],
				productdata: [],
				moreseedata: {},
				isOnLoad: true,
			}
		},
		components: {
			ActiveItem
		},
		methods: {
			goodsCodeArray() {
				this.codeList = [];//goodsCode数组
				this.productdata = [];//商品位的数据数组
				this.moreseedata = {};//图片位数据
				if(this.dataList.length == 0) {
					return
				}
				if(this.dataList && this.dataList.length > 0) {
					for(var i = 0; i < this.dataList.length; i++) {
						if(this.dataList[i].relPosition == "GOODS") {
							//this.codeList.push(this.dataList[i].goodsCode)
							this.productdata.push(this.dataList[i].goodsNewVO)
						} else if(this.dataList[i].relPosition == "IMAGE") {
							this.moreseedata = this.dataList[i]
						}
					}
					this.getDetailData()
				}
			},
			getDetailData() {
				for(var i = 0; i < this.dataList.length; i++) {
					for(var j = 0; j < this.productdata.length; j++) {
						if(this.dataList[i].goodsCode == this.productdata[j].goodsCode) {
							this.productdata[j].mainPic = this.dataList[i].publicityPicture
							this.productdata[j].regularTypeLabel = this.dataList[i].relTitle
						}
					}
				}
				// console.log("this.dataList", this.dataList);
				// console.log("productdata", this.productdata);
			},
			buttonActive(val) {
				this.$router.push({
					path: 'detail?code=' + val.goodsCode
				})
			}
		},
		computed: {
			env() {
				return window.environment; // 获取是否是编辑状态
			},
		},

		watch: {
			dataList(val) {
				console.log("dataList---val", val);
				this.goodsCodeArray()
			},
		},
		mounted() {
			// console.log("打印dataList",this.dataList)
			this.goodsCodeArray()
		},
	}
</script>

<style>
	.activitiesNinePro .proul {
		padding: 0.5rem;
		position: relative;
	}
	
	.moresee {
		width: 33.3%;
		float: left;
		height: 8.85rem;
		margin-bottom: 0.5rem;
		line-height: 8rem;
		opacity: 0.7;
		background-position: center;
		background-repeat: no-repeat;
		background-size: cover;
	}
	
	.moresee span {
		font-size: 1rem;
		color: #fff;
	}
</style>